#!/usr/bin/env python
# encoding: utf-8
# @author: Lin Han
# @contact: voldemort22@126.com
# @file: queryModels.py
# @time: 2021/3/23 11:34
# @desc:
from datetime import datetime
from typing import List, Optional, Dict

from fastapi import File
from pydantic import BaseModel


class UploadOneStandardClamp(BaseModel):
    """
    修改标准夹具信息
    """
    jsonData: Dict
    version: Optional[str]
    desc: Optional[str]


class LockFlagQuery(BaseModel):
    """
    修改 模型 标签状态
    """
    number: str
    isFlag: bool


class UpdateParamModelProperty(BaseModel):
    """
    修改 参数化模型 标签信息
    """
    number: str
    standard: Optional[List]
    category: Optional[str]
    partType: Optional[str]
    elseTag: Optional[List]


class UpdateHistoryClampConfigData(BaseModel):
    """
    修改 历史夹具 配置列表 的输入
    """
    standard: Optional[List]
    area: Optional[List]
    pinType: Optional[List]
    rpsType: Optional[List]


class UpdateHistoryClamp(BaseModel):
    """
    修改 历史夹具 tag 的输入
    """
    number: str
    area: Optional[str]
    rpsNumber: Optional[int] = 0
    airNumber: Optional[int] = 0
    hasPin: bool = False
    hasStopBlock: bool = False
    hasSensor: bool = False
    hasSucker: bool = False
    standard: List[Optional[str]] = []
    rpsType: List[Optional[str]] = []
    pinType: List[Optional[str]] = []
    elseTag: List[Optional[str]] = []


class UpdateHistoryPartConfigData(BaseModel):
    """
    修改 历史零件 配置列表
    """
    standard: Optional[List[str]]
    partType: Optional[List[dict]]
    version: Optional[List[str]]


class UpdateParamConfigData(BaseModel):
    """
    修改 参数化模型 配置列表
    """
    standard: Optional[List]
    makeType: Optional[List]
    partType: Optional[List]
    version: Optional[str]


class UpdateOneStandardClamp(BaseModel):
    """
    修改标准夹具信息
    """
    number: str
    version: str
    name: str
    desc: str


class UpdateOneStandardPart(BaseModel):
    """
    修改标准夹具信息
    """
    number: str
    version: str
    name: str
    desc: str
    partFunction: str


class MultipleConditionQueryBase(BaseModel):
    """
    多条件组合查询历史夹具信息的输入基类
    """

    keyword: Optional[str]
    startTime: Optional[datetime] = datetime.strptime("2000-01-01", "%Y-%m-%d")
    endTime: Optional[datetime] = datetime.strptime("3000-01-01", "%Y-%m-%d")
    page: Optional[int] = 1
    pagesize: Optional[int] = 10
    isTotal: bool = False


class MultipleConditionQueryHistoryClamps(MultipleConditionQueryBase):
    """
    多条件组合查询历史夹具信息
    """
    standard: Optional[str]
    area: Optional[str]
    isFeature: Optional[bool]
    isFlag: Optional[bool]
    isSceneBinded: Optional[bool]
    hasPin: Optional[bool]
    hasStopBlock: Optional[bool]
    # 如果入参里这个字段非空，即传入一堆number号，输出的数据中必须在这些number号中
    numbers: Optional[List[str]]
    rpsNumber: Optional[int]
    rpsType: List = []


class MultipleConditionQueryHistoryParts(MultipleConditionQueryBase):
    """
    多条件组合查询历史零件信息
    """
    isAbstract: bool = False
    isFeature: bool = False
    isFlag: bool = False
    standard: Optional[str]
    version: Optional[str]
    partType: Optional[str]
    # bigType: Optional[str]
    # smallType: Optional[str]
    # category: Optional[str]


class MultipleConditionQueryStandardClamps(MultipleConditionQueryBase):
    """
    多条件组合查询标准夹具信息
    """
    version: Optional[str]


class MultipleConditionQueryStandardParts(MultipleConditionQueryBase):
    """
    多条件组合查询标准零件信息
    """
    version: Optional[str]
    partFunction: Optional[str]
    partType: Optional[str]


class MultipleConditionQueryParameterModels(MultipleConditionQueryBase):
    """
    多条件组合查询参数化模型信息
    """
    isFeature: bool = False
    isFlag: bool = False
    standard: Optional[str]
    partType: Optional[str]
    category: Optional[str]


class MultipleConditionQueryTrainingData(MultipleConditionQueryBase):
    """
    多条件组合查询训练数据（场景）信息
    """
    rpsNumber: Optional[int]


class UploadModel(BaseModel):
    desc: str = File(...)
    version: str = File(...)
    isFeature: bool = False
    isFlag: bool = False
    type: str = "5"


class CreateScene(BaseModel):
    name: str
    desc: str
    rpsNumber: Optional[int]
    historyClamp: Optional[List] = []
    standardClamp: Optional[List] = []


class UpdateScene(BaseModel):
    number: str
    name: Optional[str]
    desc: Optional[str]
    rpsNumber: Optional[int]
    historyClamp: Optional[List]
    standardClamp: Optional[List]


class HistoryClampStandardClamp(BaseModel):
    history_clamp_number: str
    standard_clamp_number: str


class HistoryPartStandardPart(BaseModel):
    history_part_number: str
    standard_part_number: str


class StandardPartParameterModel(BaseModel):
    standard_part_number: str
    parameter_number: str


class HistoryPartParameterModel(BaseModel):
    history_part_number: str
    parameter_number: str


class HistoryClampSceneModel(BaseModel):
    history_clamp_number: str
    scene_number: str


class StandardClampSceneModel(BaseModel):
    standard_clamp_number: str
    scene_number: str
